Skip to content

Conversation

devgl96
Copy link

@devgl96 devgl96 commented Oct 31, 2024

Problem

I'm developing a modal component using the TimePicker, and I've encountered a problem. I'm using React and trying to implement some functionalities with useRef(). When I use the onMonthDropdownChange function, something unexpected happens.

For example: If the modal is set to October and I try to change it to June, the calendar switches to July instead.

Case Study

After researching this topic, I found that:

When using JavaScript’s new Date() to switch between months with a different number of days, a shift to the following month can occur.

Solution

To resolve this, I set the default date to the first day of the selected month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant